<table width="100%" border="0" cellspacing="0" cellpadding="0" class="delivery-info">
  <tbody>
    <tr>
      <th>收货人姓名：</th>
      <td><input type="text" name="name" value="<{$order.consignee.name}>" vtype="required" /> <span class="red">*</span></td>
      <th>送货时间：</th>
      <td><input type="text" name="time" value="<{$order.consignee.r_time}>" /></td>
      <th>收货地区：</th>
      <td><{input type="region" app='ectools' name="area" vtype="area" value="{$order.consignee.area}"}> <span class="red">*</span></td>
    </tr>
    <tr>
      <th>联系手机：</th>
      <td><input type="text" name="mobile" value="<{$order.consignee.mobile}>" id="mobile" /></td>
      <th>邮政编码：</th>
      <td><input type="text" name="zip" value="<{$order.consignee.zip}>" vtype="required" />
        <span class="red">*</span></td>
      <th>收货地址：</th>
      <td><input type="text" name="address" value="<{$order.consignee.addr}>" vtype="required" />
        <span class="red">*</span></td>
    </tr>
    <tr>
      <th>联系电话：</th>
      <td><input type="text" name="phone" value="<{$order.consignee.telephone}>" id="shop[tel]" />
      <th>Email地址：</th>
      <td><input type="text" name="email" value="<{$order.consignee.email}>" /></td>
      <th>&nbsp;</th>
      <td>&nbsp;</td>
    </tr>
    <tr><td colspan="6" style="text-align:center;"><{button label="确定" id="btn_delivery_submit" type="button"}> <{button label="取消" id="btn_delivery_reset" type="button"}></td></tr>
  </tbody>
</table>
<script>
(function(){
  var branch_id = $('dataNode').getParent().getElement('th.selected').get('data-storeid'),
   order_id = $E('[name=order_id]',$('order_split')).value;
  $('btn_delivery_submit').addEvent('click',function(){
	var gd_tel,mobile;
    gd_tel = $('shop[tel]').value.replace(" ","");
    mobile = $('mobile').value.replace(' ','');
    if (!gd_tel && !mobile){
           alert('固定电话与手机号码必需填写一项');
           $('shop[tel]').focus();
           return false;
    }
     var flag = false;
       this.getParent('.delivery-info').getElements('[vtype]').each(function(item){
         if (!validate(item)) flag=true;
       });
       if (flag) return ;
    /*new Request({url:'',method:'post',data:$('delivery_info'),
      onRequest:function(){
        return MessageBox.show('正在提交...');
      },
      onComplete:function(rs){
        if(!rs)return MessageBox.error('提交失败，请重试');
        rs = rs.decode(rs);*/
    
        var handle = $('delivery_info');
        var rs = {
            name:$E('[name=name]',handle).value,
            time:$E('[name=time]',handle).value,
            area:$E('[name=area]',handle).value.split(":")[1],
            mobile:$E('[name=mobile]',handle).value,
            zip:$E('[name=zip]',handle).value,
            address:$E('[name=address]',handle).value,
            phone:$E('[name=phone]',handle).value,
            email:$E('[name=email]',handle).value
        };
        $('other_delivery').set('html','使用其它配送信息');
        //MessageBox.success('提交成功');
        new Request.HTML({url:'index.php?app=ome&ctl=admin_order&act=do_confirm_delivery_info&p[0]='+order_id, method:'post', update:handle,
            onSuccess:function(){
                $E('[name="consignee[name]"]',handle).value = rs.name;
                $E('[name="consignee[r_time]"]',handle).value = rs.time;
                $E('[name="consignee[area]"]',handle).value = rs.area;
                $E('[name="consignee[mobile]"]',handle).value = rs.mobile;
                $E('[name="consignee[zip]"]',handle).value = rs.zip;
                $E('[name="consignee[addr]"]',handle).value = rs.address;
                $E('[name="consignee[telephone]"]',handle).value = rs.phone;
                $E('[name="consignee[email]"]',handle).value = rs.email;

                $E('[name="consignee[name]"]',handle).getParent().getElement('span').innerHTML = rs.name;
                $E('[name="consignee[r_time]"]',handle).getParent().getElement('span').innerHTML = rs.time;
                $E('[name="consignee[area]"]',handle).getParent().getElement('span').innerHTML = rs.area;
                $E('[name="consignee[mobile]"]',handle).getParent().getElement('span').innerHTML = rs.mobile;
                $E('[name="consignee[zip]"]',handle).getParent().getElement('span').innerHTML = rs.zip;
                $E('[name="consignee[addr]"]',handle).getParent().getElement('span').innerHTML = rs.address;
                $E('[name="consignee[telephone]"]',handle).getParent().getElement('span').innerHTML = rs.phone;
                $E('[name="consignee[email]"]',handle).getParent().getElement('span').innerHTML = rs.email;
                getCorps(branch_id);
            }
        }).send();
     /* }
    }).send();*/
  });
  $('btn_delivery_reset').addEvent('click',function(){
    $('other_delivery').set('html','使用其它配送信息');
    new Request.HTML({url:'index.php?app=ome&ctl=admin_order&act=do_confirm_delivery_info&p[0]='+order_id,method:'post',update:$('delivery_info'),onSuccess:function(){
            getCorps(branch_id);
        }
    }).send();
  });
})();
</script>
